package com.zzy.chapter4.facade;

import com.zzy.chapter4.pojo.Order;
import com.zzy.chapter4.strategy.context.PayContext;
import com.zzy.chapter4.strategy.factory.PayContextFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PayFacade {

    @Autowired
    private PayContextFactory payContextFactory;

    public String pay(Order order, Integer payType) {
        PayContext context = payContextFactory.getContext(payType);
        return context.execute(order);
    }

}
